%% TEXT STYLING
%
% change this info string if making any custom modification
\ProvidesFile{sphinxlatexstyletext.sty}[2021/01/27 text styling]

% to obtain straight quotes we execute \@noligs as patched by upquote, and
% \scantokens is needed in cases where it would be too late for the macro to
% first set catcodes and then fetch its argument. We also make the contents
% breakable at non-escaped . , ; ? ! / using \sphinxbreaksviaactive,
% and also at \ character (which is escaped to \textbackslash{}).
\protected\def\sphinxtextbackslashbreakbefore
 {\discretionary{}{\sphinxafterbreak\sphinx@textbackslash}{\sphinx@textbackslash}}
\protected\def\sphinxtextbackslashbreakafter
 {\discretionary{\sphinx@textbackslash}{\sphinxafterbreak}{\sphinx@textbackslash}}
\let\sphinxtextbackslash\sphinxtextbackslashbreakafter
% the macro must be protected if it ends up used in moving arguments,
% in 'alltt' \@noligs is done already, and the \scantokens must be avoided.
\protected\def\sphinxupquote#1{{\def\@tempa{alltt}%
  \ifx\@tempa\@currenvir\else
   \ifspx@opt@inlineliteralwraps
      % break at . , ; ? ! /
      \sphinxbreaksviaactive
      % break also at \
      \let\sphinx@textbackslash\textbackslash
      \let\textbackslash\sphinxtextbackslash
      % by default, no continuation symbol on next line but may be added
      \let\sphinxafterbreak\sphinxafterbreakofinlineliteral
      % do not overwrite the comma set-up
      \let\verbatim@nolig@list\sphinx@literal@nolig@list
   \fi
   % fix a space-gobbling issue due to LaTeX's original \do@noligs
% TODO: using \@noligs as patched by upquote.sty is now unneeded because
% either ` and ' are escaped (non-unicode engines) or they don't build
% ligatures (unicode engines). Thus remove this and unify handling of `, <, >,
% ' and - with the characters . , ; ? ! / as handled via
% \sphinxbreaksviaactive.
% Hence \sphinx@do@noligs will be removed, or rather replaced  with code
% inserting discretionaries, as they allow a continuation symbol on start of
% next line to achieve common design with code-blocks.
   \let\do@noligs\sphinx@do@noligs
   \@noligs\endlinechar\m@ne\everyeof{}% (<- in case inside \sphinxhref)
   \expandafter\scantokens
  \fi {{#1}}}}% extra brace pair to fix end-space gobbling issue...
\def\sphinx@do@noligs #1{\catcode`#1\active\begingroup\lccode`\~`#1\relax
    \lowercase{\endgroup\def~{\leavevmode\kern\z@\char`#1 }}}
\def\sphinx@literal@nolig@list {\do\`\do\<\do\>\do\'\do\-}%
\let\sphinxafterbreakofinlineliteral\empty

% Some custom font markup commands.
\protected\def\sphinxstrong#1{\textbf{#1}}
\protected\def\sphinxcode#1{\texttt{#1}}
\protected\def\sphinxbfcode#1{\textbf{\sphinxcode{#1}}}
\protected\def\sphinxemail#1{\textsf{#1}}
\protected\def\sphinxtablecontinued#1{\textsf{#1}}
\protected\def\sphinxtitleref#1{\emph{#1}}
\protected\def\sphinxmenuselection#1{\emph{#1}}
\protected\def\sphinxguilabel#1{\emph{#1}}
\protected\def\sphinxkeyboard#1{\sphinxcode{#1}}
\protected\def\sphinxaccelerator#1{\underline{#1}}
\protected\def\sphinxcrossref#1{\emph{#1}}
\protected\def\sphinxtermref#1{\emph{#1}}
% \optional is used for ``[, arg]``, i.e. desc_optional nodes.
\long\protected\def\sphinxoptional#1{%
  {\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}}

% additional customizable styling
\def\sphinxstyleindexentry   #1{\texttt{#1}}
\def\sphinxstyleindexextra   #1{ (\emph{#1})}
\def\sphinxstyleindexpageref #1{, \pageref{#1}}
\def\sphinxstyleindexpagemain#1{\textbf{#1}}
\protected\def\spxentry#1{#1}% will get \let to \sphinxstyleindexentry in index
\protected\def\spxextra#1{#1}% will get \let to \sphinxstyleindexextra in index
\def\sphinxstyleindexlettergroup #1%
    {{\Large\sffamily#1}\nopagebreak\vspace{1mm}}
\def\sphinxstyleindexlettergroupDefault #1%
    {{\Large\sffamily\sphinxnonalphabeticalgroupname}\nopagebreak\vspace{1mm}}
\protected\def\sphinxstyletopictitle   #1{\textbf{#1}\par\medskip}
\let\sphinxstylesidebartitle\sphinxstyletopictitle
\protected\def\sphinxstyleothertitle   #1{\textbf{#1}}
\protected\def\sphinxstylesidebarsubtitle #1{~\\\textbf{#1} \smallskip}
% \text.. commands do not allow multiple paragraphs
\protected\def\sphinxstyletheadfamily    {\sffamily}
\protected\def\sphinxstyleemphasis     #1{\emph{#1}}
\protected\def\sphinxstyleliteralemphasis#1{\emph{\sphinxcode{#1}}}
\protected\def\sphinxstylestrong       #1{\textbf{#1}}
\protected\def\sphinxstyleliteralstrong#1{\sphinxbfcode{#1}}
\protected\def\sphinxstyleabbreviation #1{\textsc{#1}}
\protected\def\sphinxstyleliteralintitle#1{\sphinxcode{#1}}
\newcommand*\sphinxstylecodecontinued[1]{\footnotesize(#1)}%
\newcommand*\sphinxstylecodecontinues[1]{\footnotesize(#1)}%
% figure legend comes after caption and may contain arbitrary body elements
\newenvironment{sphinxlegend}{\par\small}{\par}
% reduce hyperref "Token not allowed in a PDF string" warnings on PDF builds
\AtBeginDocument{\pdfstringdefDisableCommands{%
% all "protected" macros possibly ending up in section titles should be here
% TODO: examine if \sphinxhref, \sphinxurl, \sphinnolinkurl should be handled
    \let\sphinxstyleemphasis        \@firstofone
    \let\sphinxstyleliteralemphasis \@firstofone
    \let\sphinxstylestrong          \@firstofone
    \let\sphinxstyleliteralstrong   \@firstofone
    \let\sphinxstyleabbreviation    \@firstofone
    \let\sphinxstyleliteralintitle  \@firstofone
    \let\sphinxupquote  \@firstofone
    \let\sphinxstrong   \@firstofone
    \let\sphinxcode     \@firstofone
    \let\sphinxbfcode   \@firstofone
    \let\sphinxemail    \@firstofone
    \let\sphinxcrossref \@firstofone
    \let\sphinxtermref  \@firstofone
    \let\sphinxhyphen\sphinxhyphenforbookmarks
}}

% Special characters
%
% This definition prevents en-dash and em-dash TeX ligatures.
%
% It inserts a potential breakpoint after the hyphen. This is to keep in sync
% with behavior in code-blocks, parsed and inline literals. For a breakpoint
% before the hyphen use \leavevmode\kern\z@- (within \makeatletter/\makeatother)
\protected\def\sphinxhyphen#1{-\kern\z@}
% The {} from texescape mark-up is kept, else -- gives en-dash in PDF bookmark
\def\sphinxhyphenforbookmarks{-}

% For curly braces inside \index macro
\def\sphinxleftcurlybrace{\{}
\def\sphinxrightcurlybrace{\}}

% Declare Unicode characters used by linux tree command to pdflatex utf8/utf8x
\def\spx@bd#1#2{%
  \leavevmode
  \begingroup
  \ifx\spx@bd@height   \@undefined\def\spx@bd@height{\baselineskip}\fi
  \ifx\spx@bd@width    \@undefined\setbox0\hbox{0}\def\spx@bd@width{\wd0 }\fi
  \ifx\spx@bd@thickness\@undefined\def\spx@bd@thickness{.6\p@}\fi
  \ifx\spx@bd@lower    \@undefined\def\spx@bd@lower{\dp\strutbox}\fi
  \lower\spx@bd@lower#1{#2}%
  \endgroup
}%
\@namedef{sphinx@u2500}% BOX DRAWINGS LIGHT HORIZONTAL
  {\spx@bd{\vbox to\spx@bd@height}
          {\vss\hrule\@height\spx@bd@thickness
                     \@width\spx@bd@width\vss}}%
\@namedef{sphinx@u2502}% BOX DRAWINGS LIGHT VERTICAL
  {\spx@bd{\hb@xt@\spx@bd@width}
          {\hss\vrule\@height\spx@bd@height
                     \@width \spx@bd@thickness\hss}}%
\@namedef{sphinx@u2514}% BOX DRAWINGS LIGHT UP AND RIGHT
  {\spx@bd{\hb@xt@\spx@bd@width}
          {\hss\raise.5\spx@bd@height
           \hb@xt@\z@{\hss\vrule\@height.5\spx@bd@height
                                \@width \spx@bd@thickness\hss}%
           \vbox to\spx@bd@height{\vss\hrule\@height\spx@bd@thickness
                                            \@width.5\spx@bd@width\vss}}}%
\@namedef{sphinx@u251C}% BOX DRAWINGS LIGHT VERTICAL AND RIGHT
  {\spx@bd{\hb@xt@\spx@bd@width}
          {\hss
           \hb@xt@\z@{\hss\vrule\@height\spx@bd@height
                                \@width \spx@bd@thickness\hss}%
           \vbox to\spx@bd@height{\vss\hrule\@height\spx@bd@thickness
                                            \@width.5\spx@bd@width\vss}}}%
\protected\def\sphinxunichar#1{\@nameuse{sphinx@u#1}}%

% Tell TeX about pathological hyphenation cases:
\hyphenation{Base-HTTP-Re-quest-Hand-ler}

\endinput
